package jtk.project4.fleet.screen.addEditFuelReceipt;

import java.awt.FlowLayout;

import jtk.project4.fleet.field.AddEditFuelReceiptField;

import nl.coderight.jazz.form.FormField;
import nl.coderight.jazz.form.FormHeader;
import nl.coderight.jazz.form.FormView;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.button.PushButton;

public class AddEditFuelReceiptView extends FormView {

	private FormHeader formHeader;
	private PushButton saveButton;
	private PushButton cancelButton;
	
	protected void init(){
		createFields();
		createLayout();
	}
	
	
	private FormHeader createHeader() {
		formHeader = new FormHeader();
		formHeader.setTitle("add.fuel receipt.header.form");
		return formHeader;
	}
	
	private void createLayout() {
		setHeader(createHeader());
		addField(createForm());
	}
	
	private FormField createForm()
	{
		GroupControl form = new GroupControl();
		form.addField(new AddEditFuelReceiptField("Add Fuel Receipt"), NORTH);
		form.addField(createButtons(), SOUTH);
		return form;
	}
	
	private void createFields() {
		saveButton = new PushButton("saveAction");
		cancelButton = new PushButton("cancelAction");
	}
	
	private GroupControl createButtons() {
		GroupControl buttons = new GroupControl();
		buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
		buttons.addField(saveButton);
		buttons.addField(cancelButton);
		return buttons;
	}
	

}
